# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=java-postgresql-jdbc
_pkgname=postgresql-jdbc
pkgver=42.2.10
pkgrel=0
pkgdesc="Java JDBC 4.2 (JRE 8+) driver for PostgreSQL database"
url="https://jdbc.postgresql.org"
arch="noarch !mips !mips64"
license="BSD-3-Clause"
depends=""
makedepends="openjdk8 maven"
source="$pkgname-$pkgver.tar.gz::https://github.com/pgjdbc/pgjdbc/archive/REL$pkgver.tar.gz"
builddir="$srcdir/pgjdbc-REL$pkgver/pgjdbc"

build() {
	cd "$builddir"

	# Note: Maven downloads quite many dependencies from Maven Central, but
	# these are used only for building, not bundled to the final JAR.
	export JAVA_HOME="/usr/lib/jvm/default-jvm"
	mvn package -DskipTests -Dmaven.repo.local="$builddir/.m2"
}

package() {
	cd "$builddir"

	install -m 644 -D target/postgresql-$pkgver.jar \
		"$pkgdir"/usr/share/java/$_pkgname-$pkgver.jar || return 1
	ln -s $_pkgname-$pkgver.jar "$pkgdir"/usr/share/java/$_pkgname.jar
}

sha512sums="1fc2e8b4d6d5826de5722d1ec4c9cf9f45b2b984c1e7d3a5bf97421b2b8e358c8d63869d894fe41573c396366cc43cf2dbe953fef8568648f0a49838a4da500e  java-postgresql-jdbc-42.2.10.tar.gz"
